﻿using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
using Pomelo.EntityFrameworkCore.MySql.Scaffolding.Internal;

namespace UtilsORM.FileServerData;

public partial class FileServerDataContext : DbContext
{
    public FileServerDataContext()
    {
    }

    public FileServerDataContext(DbContextOptions<FileServerDataContext> options)
        : base(options)
    {
    }

    public virtual DbSet<bs_client> bs_client { get; set; }

    public virtual DbSet<bs_client_department> bs_client_department { get; set; }

    public virtual DbSet<bs_client_level> bs_client_level { get; set; }

    public virtual DbSet<bs_client_module> bs_client_module { get; set; }

    public virtual DbSet<bs_client_post> bs_client_post { get; set; }

    public virtual DbSet<bs_client_product_bak> bs_client_product_bak { get; set; }

    public virtual DbSet<bs_client_role> bs_client_role { get; set; }

    public virtual DbSet<bs_client_role_menu> bs_client_role_menu { get; set; }

    public virtual DbSet<bs_client_role_power> bs_client_role_power { get; set; }

    public virtual DbSet<bs_client_system_log> bs_client_system_log { get; set; }

    public virtual DbSet<bs_client_user> bs_client_user { get; set; }

    public virtual DbSet<bs_client_user_dep> bs_client_user_dep { get; set; }

    public virtual DbSet<bs_client_user_role> bs_client_user_role { get; set; }

    public virtual DbSet<bs_manage_role> bs_manage_role { get; set; }

    public virtual DbSet<bs_manage_role_menu> bs_manage_role_menu { get; set; }

    public virtual DbSet<bs_manage_role_power> bs_manage_role_power { get; set; }

    public virtual DbSet<bs_manage_system_log> bs_manage_system_log { get; set; }

    public virtual DbSet<bs_manage_system_menu> bs_manage_system_menu { get; set; }

    public virtual DbSet<bs_manage_system_module> bs_manage_system_module { get; set; }

    public virtual DbSet<bs_manage_user_role> bs_manage_user_role { get; set; }

    public virtual DbSet<f_file> f_file { get; set; }

    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see https://go.microsoft.com/fwlink/?LinkId=723263.
        => optionsBuilder.UseMySql("server=8.134.154.134;port=2206;database=file-server;uid=yueju;pwd=yueju?456123Z;sslmode=none;allowpublickeyretrieval=True", Microsoft.EntityFrameworkCore.ServerVersion.Parse("8.0.36-mysql"));

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder
            .UseCollation("utf8mb4_general_ci")
            .HasCharSet("utf8mb4");

        modelBuilder.Entity<bs_client>(entity =>
        {
            entity.HasKey(e => e.c_id).HasName("PRIMARY");

            entity.Property(e => e.c_power_type).HasComment("operator运营,general普通");
            entity.Property(e => e.c_status).HasDefaultValueSql("'0'");
        });

        modelBuilder.Entity<bs_client_department>(entity =>
        {
            entity.HasKey(e => e.dep_id).HasName("PRIMARY");

            entity.Property(e => e.dep_cpy_guid).HasComment("对应pm_company");
            entity.Property(e => e.dep_status).HasComment("0有效，1无效");
            entity.Property(e => e.dep_type).HasComment("1项目部门，2职能部门");
        });

        modelBuilder.Entity<bs_client_level>(entity =>
        {
            entity.HasKey(e => e.L_AutoID).HasName("PRIMARY");
        });

        modelBuilder.Entity<bs_client_module>(entity =>
        {
            entity.HasKey(e => e.cm_autoid).HasName("PRIMARY");

            entity.Property(e => e.cm_autoid).ValueGeneratedNever();
        });

        modelBuilder.Entity<bs_client_post>(entity =>
        {
            entity.HasKey(e => e.P_AutoID).HasName("PRIMARY");

            entity.Property(e => e.P_IsValid).HasComment("1有效，-1无效");
        });

        modelBuilder.Entity<bs_client_product_bak>(entity =>
        {
            entity.HasKey(e => e.cp_id).HasName("PRIMARY");

            entity.Property(e => e.cp_c_guid).HasComment("客户ID");
            entity.Property(e => e.cp_ip).HasComment("远程IP地址");
            entity.Property(e => e.cp_name).HasComment("产品名称");
            entity.Property(e => e.cp_product_guid).HasComment("产品ID");
            entity.Property(e => e.cp_status)
                .HasDefaultValueSql("'0'")
                .HasComment("0有效，1无效");
            entity.Property(e => e.cp_systemcode).HasComment("系统编码");
        });

        modelBuilder.Entity<bs_client_role>(entity =>
        {
            entity.HasKey(e => e.r_id).HasName("PRIMARY");

            entity.Property(e => e.r_status).HasComment("0正常，1禁用");
        });

        modelBuilder.Entity<bs_client_role_menu>(entity =>
        {
            entity.HasKey(e => e.rm_id).HasName("PRIMARY");
        });

        modelBuilder.Entity<bs_client_role_power>(entity =>
        {
            entity.HasKey(e => e.rp_id).HasName("PRIMARY");
        });

        modelBuilder.Entity<bs_client_system_log>(entity =>
        {
            entity.HasKey(e => e.l_id).HasName("PRIMARY");

            entity.Property(e => e.l_c_guid).HasComment("租户");
            entity.Property(e => e.l_content).HasComment("操作内容");
            entity.Property(e => e.l_cu_name).HasComment("名字");
            entity.Property(e => e.l_ip).HasComment("ip");
            entity.Property(e => e.l_source).HasComment("来源");
            entity.Property(e => e.l_system).HasComment("系统");
        });

        modelBuilder.Entity<bs_client_user>(entity =>
        {
            entity.HasKey(e => e.cu_id).HasName("PRIMARY");

            entity.Property(e => e.cu_c_guid)
                .HasDefaultValueSql("'newid())'")
                .HasComment("关联client");
            entity.Property(e => e.cu_guid).HasDefaultValueSql("'newid())'");
            entity.Property(e => e.cu_power_type).HasComment("super超级,general普通");
            entity.Property(e => e.cu_status)
                .HasDefaultValueSql("'0'")
                .HasComment("0正常，1禁用");
        });

        modelBuilder.Entity<bs_client_user_dep>(entity =>
        {
            entity.HasKey(e => e.cud__id).HasName("PRIMARY");

            entity.Property(e => e.cud_type).HasComment("1直属部门 ,2兼管部门");
        });

        modelBuilder.Entity<bs_client_user_role>(entity =>
        {
            entity.HasKey(e => e.ur_id).HasName("PRIMARY");
        });

        modelBuilder.Entity<bs_manage_role>(entity =>
        {
            entity.HasKey(e => e.r_id).HasName("PRIMARY");

            entity.Property(e => e.r_status).HasComment("0正常，1禁用");
        });

        modelBuilder.Entity<bs_manage_role_menu>(entity =>
        {
            entity.HasKey(e => e.rm_id).HasName("PRIMARY");
        });

        modelBuilder.Entity<bs_manage_role_power>(entity =>
        {
            entity.HasKey(e => e.rp_id).HasName("PRIMARY");
        });

        modelBuilder.Entity<bs_manage_system_log>(entity =>
        {
            entity.HasKey(e => e.l_id).HasName("PRIMARY");

            entity.Property(e => e.l_c_guid).HasComment("租户");
            entity.Property(e => e.l_content).HasComment("操作内容");
            entity.Property(e => e.l_cu_name).HasComment("名字");
            entity.Property(e => e.l_ip).HasComment("ip");
            entity.Property(e => e.l_source).HasComment("来源");
            entity.Property(e => e.l_system).HasComment("系统");
        });

        modelBuilder.Entity<bs_manage_system_menu>(entity =>
        {
            entity.HasKey(e => e.menu_id).HasName("PRIMARY");

            entity.Property(e => e.menu_status).HasComment("0正常，-1停用");
        });

        modelBuilder.Entity<bs_manage_system_module>(entity =>
        {
            entity.HasKey(e => e.M_AutoId).HasName("PRIMARY");

            entity.Property(e => e.M_AutoId).ValueGeneratedNever();
            entity.Property(e => e.M_Code).HasComment("编码");
            entity.Property(e => e.M_Name).HasComment("模块名称");
            entity.Property(e => e.M_Order).HasComment("排序");
            entity.Property(e => e.M_Status).HasComment("1启用，0禁用");
        });

        modelBuilder.Entity<bs_manage_user_role>(entity =>
        {
            entity.HasKey(e => e.ur_id).HasName("PRIMARY");
        });

        modelBuilder.Entity<f_file>(entity =>
        {
            entity.HasKey(e => e.id).HasName("PRIMARY");

            entity.Property(e => e.code).HasComment("编号");
            entity.Property(e => e.create_time).HasComment("路径");
            entity.Property(e => e.del_code).HasComment("删除代码");
            entity.Property(e => e.extension).HasComment("文件扩展名");
            entity.Property(e => e.from).HasComment("来源");
            entity.Property(e => e.level).HasComment("层级");
            entity.Property(e => e.name).HasComment("名称");
            entity.Property(e => e.parent_id).HasComment("父级");
            entity.Property(e => e.size).HasComment("大小,kb");
            entity.Property(e => e.space_type).HasComment("0个人空间，1公共空间");
            entity.Property(e => e.status).HasComment("0正常，1删除");
            entity.Property(e => e.system_name).HasComment("系统名称");
            entity.Property(e => e.type).HasComment("dir,file");
            entity.Property(e => e.url).HasComment("名称");
        });

        OnModelCreatingPartial(modelBuilder);
    }

    partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
}
